# 用于控制舵机的角度

from car_pca9685 import PCA9685


class Servo(object):
    _instance = None

    def __new__(cls, *args, **kw):
        if cls._instance is None:
            cls._instance = object.__new__(cls, *args, **kw)
        return cls._instance

    def __init__(self, address=0X41, debug=False):
        """
        :param address：pca9685的地址，默认是0x41
        :param debug：是否显示调试信息
        """
        self.pca = PCA9685(address=address, frequency=50, debug=debug)
        pass
    def set_servo_angle(self, channel, angle):
        """
        :param channel:舵机所使用的PCA9685通道（0~15）
        :param angle:控制舵机转动的角度（0~180度）
        """
        self.pca.set_servo_angle(channel, angle)
        pass


if __name__ == '__main__':
    servo = Servo()
    servo1 = Servo()
    print(id(servo) == id(servo1))
